<?php
/**
 * 功能: 攻略展示
 * User: 文丹
 * Date: 2018/7/10 0010
 * Time: 15:43
 */

namespace app\index\controller;
use think\Controller;

class Strategy extends Controller{
    /**
     * 攻略列表展示
     */
    public function index(){
        $strategy = model('Strategy')->getStrategy();
        if($strategy){
            return json(['msg'=>'请求成功','ok'=>true,'strategy'=>$strategy]);
        }else{
            return json(['msg'=>'暂无数据','ok'=>false]);
        }
    }
    /**
     * 单个攻略详情
     */
    public function detail(){
        $id = intval(input('id'));
        if($id<=0){
            return json(['msg'=>'id必须为正整数','ok'=>false]);
        }
        $detail = model('Strategy')->getDetail($id);
        if($detail){
            return json(['msg'=>'请求成功','ok'=>true,'detail'=>$detail]);
        }else{
            return json(['msg'=>'数据为空','ok'=>false]);
        }
    }

}